package com.trkj.dao.jpa;


import java.math.BigDecimal;
import java.sql.Date;
import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.JlRegistration;

public interface IjlregisterDAO extends CrudRepository<JlRegistration, Long>{
	
	//根据id查找所有挂号信息返回集合
	@Query("select s from JlRegistration s where ireId=?1")
	public List<JlRegistration> findByregisid(long ireId); 	
	//查找所有挂号信息返回对象
	@Query("select s from JlRegistration s order by reCallNum")
	public List<JlRegistration> findreginByPage(Pageable pageable);
	
	@Query("select s from JlRegistration s where reAdministrative=?1")
	public List<JlRegistration> findbyreks (String sex);
	
	@Query("select s from JlRegistration s where rePhysician=?1")
	public List<JlRegistration> findbyreys (String sex);
	
	@Query("select s from JlRegistration s where reWay=?1")
	public List<JlRegistration> findbyrefs (String sex);
	
	@Query("select s from JlRegistration s where rePayFees=?1")
	public List<JlRegistration> findbyrejf(String sex);
	
	//查找最大的日期
	@Query("select max(reDate) from JlRegistration")
	public Date findMaxregtimByPage();
	//查找最大的呼叫号
	@Query("select max(reCallNum) from JlRegistration where state is null")
	public BigDecimal findMaxreghjhByPage();
	//查找最小的呼叫号
	@Query("select min(reCallNum) from JlRegistration where state is null")
	public BigDecimal findminreghjhByPage();
	//根据呼叫号查找用户卡号
	@Query("select ireId from JlRegistration  where reCallNum=?1")
	public BigDecimal findbyIreId(BigDecimal callnum);
	//根据呼叫号查找用户卡号
	@Query("select s from JlRegistration s where s.reCallNum=?1")
	public JlRegistration findbyregin(BigDecimal CallNum);
}
